<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
	<meta name="format-detection" content="telephone=no,address=no,email=no"/>
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<title>KAA电商管理后台_积分管理</title>
	<script type="text/javascript" src="${path}/js/jquery-2.1.1.min.js"></script>
	<script src="${path}/js/sidebar-menu.js"></script>
	<link href="${path}/css/login.css" rel="stylesheet" media="all">
</head>
<script language="JavaScript">

    function checkboxAll() {
        var checkstr = "";
        $("input:checkbox[name=id]:checked").each(function (i) {
            if (checkstr != "") {    //将所选的各项记录的id形成字符串，并以“，”分割
                checkstr += ",";
            }
            checkstr += $(this).val();
        });
        $("#checkBoxId").val(checkstr)
    }
	/* 是否全选标记 */
    var checkedAll = false;
	/* 全选/取消全选
	 * formName 所在form的name值
	 * checkboxName checkbox的name值
	 * 注意：所有checkbox的name值都必须一样，这样才能达到全选的效果
	 */
    function selectAll(form1, id) {
        var form = document.all.item(form1);
		/* var elements = form.elements[id];*/
        var elements = document.getElementsByTagName("input");
        for (var i = 0; i < elements.length; i++) {
            var e = elements[i];
            if (checkedAll) {
                e.checked = false;
                form.alls.checked = false;
            } else {
                e.checked = true;
                form.alls.checked = true;
                var checkstr = "";
                $("input:checkbox[name=id]:checked").each(function (i) {
                    if (checkstr != "") {    //将所选的各项记录的id形成字符串，并以“，”分割
                        checkstr += ",";
                    }
                    checkstr += $(this).val();
                });
                $("#ids").val(checkstr)
            }
        }
        if (checkedAll) {
            checkedAll = false;
        } else {
            checkedAll = true;
        }
    }

    function selectDate(value){
        $.ajax({
            type : "post",
            url : "${path}/integralList?date="+value+"",
            data : "date="+ value,
            success:function(date){
                $("#pageCotent").html(date);
            },
        });
    }
    function selectIntegral(value){
        $.ajax({
            type : "post",
            url : "${path}/integralList?integral="+value+"",
            data : "integral="+ value,
            success:function(date){
                $("#pageCotent").html(date);
            },
        });
    }
    function selectLevel(value){
        $.ajax({
            type : "post",
            url : "${path}/integralList?level="+value+"",
            data : "level="+ value,
            success:function(date){
                $("#pageCotent").html(date);
            },
        });
    }

</script>
<body class="main" id="pageCotent">
	<h1>KAA电商管理后台</h1>
	<jsp:include page="sidebarNav.jsp"></jsp:include><!-- main_sidebar -->

	<div class="main_con_wrap">
		<form name="form1" method="post"
			  action="${path}/integralList" id="form1">
			<div class="main_con_top1 memberlist_top1">
				<%--<p class="outline_in"><a>会员添加</a></p>--%>
				<p class="del_all"><label for="del_all"></label><input name="alls" type="checkbox" onClick="selectAll('form1','id')"/><span>全选</span></p>
				<p class="outline_in"><input type="button" onclick="delAll()" value="积分清零" /></p>
				<%--<p class="outline_in"><input type="button" onclick="checkmb('chk')" value="000" /></p>--%>
				<%--<p class="recycle_bin"><a></a></p>--%>
				<div class="search_wrap">
					<form id="member_search" name="member_search" action="${path}/integralList " method="get">
						<div class="search_fl">
							<input type="text" placeholder="输入搜索内容" name="userName" class="search_txt" value="${userNames}">
						</div>
						<input type="submit" value="" name="member_search_btn" class="search_btn">
					</form>
				</div>
				<span class="clear"></span>
			</div><!-- main_con_top1 -->
		<div class="main_con member_list">
			<div class="main_con_top2 memberlist_top2">
				<p>
					<select id="memberlist_time" onchange="selectDate(this.value);">
						<option selected="" value=""value=""${date == null ? 'selected':""}>按注册时间</option>
						<option value="0"${date == 0 ? 'selected':""}>降序</option>
						<option value="1"${date == 1 ? 'selected':""}>升序</option>
					</select>
				</p>

				<p>
					<select id="memberlist_source"onchange="selectIntegral(this.value);">
						<option selected="" value=""${integral == null ? 'selected':""}>选择积分值</option>
						<option value="0"${integral == 0 ? 'selected':""}>降序</option>
						<option value="1"${integral == 1 ? 'selected':""}>升序</option>
					</select>
				</p>
				<p>
					<select id="memberlist_cat" onchange="selectLevel(this.value);">
						<option selected="" value=""${level == null ? 'selected':""}>选择会员组</option>
						<c:forEach items="${memberGroupList}" var="item">
							<option value="${item.memberLevel}"${ level == item.memberLevel ? 'selected':""}>${item.memberLevel}</option>
						</c:forEach>
					</select>
				</p>
				<%--<div class="excelbut"><input class="excelin" id="excelbut2" type="button" value="" onclick="javascript:method('memberlist_table')" /></div>
				<div class="excelbut excelout_wrap"><input class="excelout" id="excelbut1" type="button" value="" onclick="javascript:method('memberlist_table')" /></div>--%>
				<div class="clear"></div>
			</div><!-- main_con_top2 -->
			<table id="memberintegral_table" width="100%" border="0" align="center">
				<tr>
					<th>选择<input name="id" id="Checkbox1"
								 onclick="checkboxAll();" value="" class="np"
								 style="display: none;" type="checkbox"></th>
					<th>会员编号</th>
					<th>用户名</th>
					<th>注册日期</th>
					<th>会员组</th>
					<th>会员积分</th>
					<th>操作</th>
				</tr>
				<c:forEach items="${memberUserList}" var="items">
				<tr>
					<td><input name="id" id="id" onclick="checkboxAll();"
							   value="${items.id}" class="np" type="checkbox"></td>
					<td><span>${items.memberCode}</span><input type="text" style="display:none;"></td>
					<td><span>${items.userName}</span><input type="text" style="display:none;"></td>
					<td><span>${items.startDate}</span><input type="text" style="display:none;"></td>
					<td><span>${items.level}</span><input type="text" style="display:none;"></td>
					<td>
						<span id="change_${items.id}" style="display: block">${items.integral}</span>
						<span id="change1_${items.id}" style="display: none"><input id="integral_${items.id}" name="integral_${items.id}" value="${items.integral}"type="text"></span>
					</td>
					<td class="last_td">
					<input class="edit_but" value="充值" onclick="toRecharge(${items.id})" id="toRecharge_${items.id}" type="button" style="display: block">
					<input class="edit_but" value="确认" onclick="recharge(${items.id})" id="recharge_${items.id}" type="button" style="display: none">
					</td>
				</tr>
				</c:forEach>
			</table>
			<div class="paging_wrap paging" onselectstart="return false" >
				<%--<td colspan="6" align="center" bgcolor="#5BA8DE">共${page.totalRecords}条
					记录 共${page.totalPages}页 当前第${page.pageNo}页<br>--%>
					<div class="otherBtns">
						<a class="onepage" value="首页"href="${path}/integralList?pageNo=${page.topPageNo }">首页</a>
						<c:choose>
							<c:when test="${page.pageNo!=1}">
								<a class="prevpage" value="上一页" name="previousPage" href="${path}/integralList?pageNo=${page.previousPageNo}"></a>
							</c:when>
							<c:otherwise>
								<a class="prevpage" value="上一页" name="previousPage"></a>
							</c:otherwise>
						</c:choose>
					</div>
					<div class="otherBtns">
						<c:choose>
							<c:when test="${page.pageNo != page.totalPages}">
								<a class="nextpage" value="下一页"  href="${path}/integralList?pageNo=${page.nextPageNo}"></a>
							</c:when>
							<c:otherwise>
								<a class="nextpage" value="下一页" ></a>
							</c:otherwise>
						</c:choose>
						<a value="尾页" href="${path}/integralList?pageNo=${page.bottomPageNo }">尾页</a>
					</div>
					<div class="jumpBtns" style="display:none;">
						<input class="jump_input" data="" type="text">
						<a class="jump_a" data="0">跳转</a>
					</div>
					<br><br>
					<td colspan="6" align="center" bgcolor="#5BA8DE">共${page.totalRecords}条
						记录 共${page.totalPages}页 当前第${page.pageNo}页<br>
			</div>
		</div><!-- main_con -->
		</form>
	</div><!-- main_con_wrap -->
	<form name="form2" method="post"
		  action="${path}/deleteIntegral" id="form2"
		  class="form2">
		<input name="ids" id="ids" type="hidden">
	</form>

	<form name="form3" method="post"
		  action="${path}/updateMember" id="form3"
		  class="form3">
		<input name="integralId" id="integralId" type="hidden">
		<input name="integral" id="integral" type="hidden">
	</form>
	<div class="footer_copyright">
		<p>苏州知行合一网络科技有限公司提供技术支持，版权所有</p>
	</div><!-- footer_copyright -->

<script>
	/////////////////////////侧边栏按钮
	$.sidebarMenu($('.sidebar-menu'))

    /////////////////////////创建全选
	//EDIT TR



    	function toRecharge(value) {
        	$("#toRecharge_"+value).css("display","none");
        	$("#recharge_"+value).css("display","block");
        	$("#change_"+value).css("display","none");
       	 $("#change1_"+value).css("display","block");

   	 }
            
			function recharge(value) {
                var integral =$("#integral_"+value).val();
                $("#integralId").val(value)
				$("#integral").val(integral)
				document.getElementById("form3").submit();
            }

    function delAll(){
        var elements = document.getElementsByTagName("input");
        for (var i = 0; i < elements.length; i++) {
            var checkstr = "";
            $("input:checkbox[name=id]:checked").each(function (i) {
                if (checkstr != "") {    //将所选的各项记录的id形成字符串，并以“，”分割
                    checkstr += ",";
                }
                checkstr += $(this).val();
            });
            $("#ids").val(checkstr)
        }
        document.getElementById("form2").submit();
    }
</script>
</body>
</html>